package com.huazai.juc.cec.thread.august.seventeen;

import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/**
 * @author Seon
 * @date 2022/8/17 11:33
 */
@Slf4j
public final class Singleton implements Serializable {
    private Singleton() {
    }
    private static volatile Singleton INSTANCE = null;
    public static Singleton getInstance() {
        if (INSTANCE == null) {
            synchronized (Singleton.class) {
                if (INSTANCE == null) {
                    INSTANCE = new Singleton();
                }
            }
        }
        return INSTANCE;
    }

    /**
     * 为了防止范徐丽华破坏单例模式
     * @return
     */
    public Object readResolve() {
        return INSTANCE;
    }

}
